import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
var _excluded = ["paramType"],
    _excluded2 = ["menuId", "permissionCodes"];
import request from 'utils/request';
import { CPAAS_IAM, CPAAS_PLATFORM } from 'utils/config';
import { parseParameters, filterNullValueObject, getCurrentOrganizationId, isTenantRoleLevel } from 'utils/utils';
var tenantId = getCurrentOrganizationId();
var organizationRoleLevel = isTenantRoleLevel();
export function queryMenuTree() {
  return _queryMenuTree.apply(this, arguments);
}

function _queryMenuTree() {
  _queryMenuTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
    var params,
        query,
        _args = arguments;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
            query = filterNullValueObject(parseParameters(params));
            return _context.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/menus/manage-tree"), {
              query: query
            }));

          case 3:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryMenuTree.apply(this, arguments);
}

export function queryOrganizationMenuTree(_x, _x2) {
  return _queryOrganizationMenuTree.apply(this, arguments);
}

function _queryOrganizationMenuTree() {
  _queryOrganizationMenuTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(organizationId, params) {
    var query;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            query = filterNullValueObject(parseParameters(params));
            return _context2.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/menus/manage-tree"), {
              query: query
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _queryOrganizationMenuTree.apply(this, arguments);
}

export function queryLabelList() {
  return _queryLabelList.apply(this, arguments);
}

function _queryLabelList() {
  _queryLabelList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
    var params,
        _args3 = arguments;
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
            return _context3.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/v1/").concat(tenantId, "/labels/by-type") : "".concat(CPAAS_IAM, "/v1/labels/by-type"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _queryLabelList.apply(this, arguments);
}

export function queryMenuLabel(_x3) {
  return _queryMenuLabel.apply(this, arguments);
}
/**
 * 查询搜索字段-标签 数据
 * @export
 * @param {*} param
 * @returns
 */

function _queryMenuLabel() {
  _queryMenuLabel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(params) {
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            return _context4.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/v1/").concat(tenantId, "/label-rels/MENU/").concat(params) : "".concat(CPAAS_IAM, "/v1/label-rels/MENU/").concat(params), {
              method: 'GET'
            }));

          case 1:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _queryMenuLabel.apply(this, arguments);
}

export function querySearchLabels(_x4) {
  return _querySearchLabels.apply(this, arguments);
}

function _querySearchLabels() {
  _querySearchLabels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(param) {
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            return _context5.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/v1/").concat(tenantId, "/labels/by-type") : "".concat(CPAAS_IAM, "/v1/labels/by-type"), {
              method: 'GET',
              query: param
            }));

          case 1:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _querySearchLabels.apply(this, arguments);
}

export function checkMenuDirExists() {
  return _checkMenuDirExists.apply(this, arguments);
}
/**
 * 查询值集
 * @async
 * @function queryCode
 * @param {object} params - 查询条件
 * @param {!string} param.lovCode - 查询条件
 * @returns {object} fetch Promise
 */

function _checkMenuDirExists() {
  _checkMenuDirExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
    var params,
        _args6 = arguments;
    return _regeneratorRuntime.wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
            return _context6.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/check-duplicate") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/check-duplicate"), {
              method: 'POST',
              body: params
            }));

          case 2:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));
  return _checkMenuDirExists.apply(this, arguments);
}

export function queryCode() {
  return _queryCode.apply(this, arguments);
}

function _queryCode() {
  _queryCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
    var params,
        _args7 = arguments;
    return _regeneratorRuntime.wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
            return _context7.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/lovs/value"), {
              query: params
            }));

          case 2:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  }));
  return _queryCode.apply(this, arguments);
}

export function queryDir() {
  return _queryDir.apply(this, arguments);
}

function _queryDir() {
  _queryDir = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
    var params,
        _args8 = arguments;
    return _regeneratorRuntime.wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
            return _context8.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/menus/dir"), {
              query: params
            }));

          case 2:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  }));
  return _queryDir.apply(this, arguments);
}

export function queryOrganizationDir() {
  return _queryOrganizationDir.apply(this, arguments);
}

function _queryOrganizationDir() {
  _queryOrganizationDir = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
    var params,
        organizationId,
        _args9 = arguments;
    return _regeneratorRuntime.wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
            organizationId = _args9.length > 1 ? _args9[1] : undefined;
            return _context9.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/menus/dir"), {
              query: params
            }));

          case 3:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  }));
  return _queryOrganizationDir.apply(this, arguments);
}

export function createDir() {
  return _createDir.apply(this, arguments);
}

function _createDir() {
  _createDir = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
    var data,
        _args10 = arguments;
    return _regeneratorRuntime.wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            data = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
            return _context10.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/menus/create"), {
              method: 'POST',
              body: data
            }));

          case 2:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10);
  }));
  return _createDir.apply(this, arguments);
}

export function createOrganizationDir() {
  return _createOrganizationDir.apply(this, arguments);
}

function _createOrganizationDir() {
  _createOrganizationDir = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
    var data,
        organizationId,
        _args11 = arguments;
    return _regeneratorRuntime.wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            data = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
            organizationId = _args11.length > 1 ? _args11[1] : undefined;
            return _context11.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/menus/create"), {
              method: 'POST',
              body: data
            }));

          case 3:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11);
  }));
  return _createOrganizationDir.apply(this, arguments);
}

export function saveDir() {
  return _saveDir.apply(this, arguments);
}

function _saveDir() {
  _saveDir = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
    var data,
        _args12 = arguments;
    return _regeneratorRuntime.wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            data = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
            return _context12.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/menus/update"), {
              method: 'POST',
              body: data
            }));

          case 2:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12);
  }));
  return _saveDir.apply(this, arguments);
}

export function saveOrganizationDir() {
  return _saveOrganizationDir.apply(this, arguments);
}

function _saveOrganizationDir() {
  _saveOrganizationDir = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
    var data,
        organizationId,
        _args13 = arguments;
    return _regeneratorRuntime.wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            data = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
            organizationId = _args13.length > 1 ? _args13[1] : undefined;
            return _context13.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/menus/update"), {
              method: 'POST',
              body: data
            }));

          case 3:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13);
  }));
  return _saveOrganizationDir.apply(this, arguments);
}

export function importMenu(_x5) {
  return _importMenu.apply(this, arguments);
}

function _importMenu() {
  _importMenu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(params) {
    return _regeneratorRuntime.wrap(function _callee14$(_context14) {
      while (1) {
        switch (_context14.prev = _context14.next) {
          case 0:
            return _context14.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/menus/standard-menu-import"), {
              method: 'POST',
              body: params,
              responseType: 'text'
            }));

          case 1:
          case "end":
            return _context14.stop();
        }
      }
    }, _callee14);
  }));
  return _importMenu.apply(this, arguments);
}

export function importOrganizationMenu(_x6, _x7) {
  return _importOrganizationMenu.apply(this, arguments);
}

function _importOrganizationMenu() {
  _importOrganizationMenu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(organizationId, params) {
    return _regeneratorRuntime.wrap(function _callee15$(_context15) {
      while (1) {
        switch (_context15.prev = _context15.next) {
          case 0:
            return _context15.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/menus/custom-menu-import"), {
              method: 'POST',
              body: params,
              responseType: 'text'
            }));

          case 1:
          case "end":
            return _context15.stop();
        }
      }
    }, _callee15);
  }));
  return _importOrganizationMenu.apply(this, arguments);
}

export function queryPermissions() {
  return _queryPermissions.apply(this, arguments);
}

function _queryPermissions() {
  _queryPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
    var params,
        _args16 = arguments;
    return _regeneratorRuntime.wrap(function _callee16$(_context16) {
      while (1) {
        switch (_context16.prev = _context16.next) {
          case 0:
            params = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {};
            return _context16.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/permissions/self") : "".concat(CPAAS_IAM, "/cpaas/v1/permissions/self"), {
              query: params
            }));

          case 2:
          case "end":
            return _context16.stop();
        }
      }
    }, _callee16);
  }));
  return _queryPermissions.apply(this, arguments);
}

export function deleteMenu(_x8) {
  return _deleteMenu.apply(this, arguments);
}

function _deleteMenu() {
  _deleteMenu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(id) {
    return _regeneratorRuntime.wrap(function _callee17$(_context17) {
      while (1) {
        switch (_context17.prev = _context17.next) {
          case 0:
            return _context17.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/menus/").concat(id), {
              method: 'DELETE'
            }));

          case 1:
          case "end":
            return _context17.stop();
        }
      }
    }, _callee17);
  }));
  return _deleteMenu.apply(this, arguments);
}

export function deleteOrganizationMenu(_x9, _x10) {
  return _deleteOrganizationMenu.apply(this, arguments);
} // 查询权限集

function _deleteOrganizationMenu() {
  _deleteOrganizationMenu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(id, organizationId) {
    return _regeneratorRuntime.wrap(function _callee18$(_context18) {
      while (1) {
        switch (_context18.prev = _context18.next) {
          case 0:
            return _context18.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/menus/").concat(id), {
              method: 'DELETE'
            }));

          case 1:
          case "end":
            return _context18.stop();
        }
      }
    }, _callee18);
  }));
  return _deleteOrganizationMenu.apply(this, arguments);
}

export function queryPermissionSetTree(_x11) {
  return _queryPermissionSetTree.apply(this, arguments);
}
/**
 * 启用禁用权限集及其下的所有子权限集
 * @async
 * @function setPermissionSetEnable
 * @param {!number} menuId - 查询条件
 * @param {!params} param - 查询条件
 * @param {!params} param.enableFlag - 是否启用
 * @returns {object} fetch Promise
 */

function _queryPermissionSetTree() {
  _queryPermissionSetTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(menuId) {
    var params,
        _args19 = arguments;
    return _regeneratorRuntime.wrap(function _callee19$(_context19) {
      while (1) {
        switch (_context19.prev = _context19.next) {
          case 0:
            params = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : {};
            return _context19.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/").concat(menuId, "/permission-set") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/").concat(menuId, "/permission-set"), {
              query: params
            }));

          case 2:
          case "end":
            return _context19.stop();
        }
      }
    }, _callee19);
  }));
  return _queryPermissionSetTree.apply(this, arguments);
}

export function setPermissionSetEnable(_x12) {
  return _setPermissionSetEnable.apply(this, arguments);
} // 查询权限集下可分配的所有权限

function _setPermissionSetEnable() {
  _setPermissionSetEnable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(params) {
    var paramType, others;
    return _regeneratorRuntime.wrap(function _callee20$(_context20) {
      while (1) {
        switch (_context20.prev = _context20.next) {
          case 0:
            paramType = params.paramType, others = _objectWithoutProperties(params, _excluded);
            return _context20.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/").concat(paramType) : "".concat(CPAAS_IAM, "/cpaas/v1/menus/").concat(paramType), {
              body: others,
              method: 'PUT'
            }));

          case 2:
          case "end":
            return _context20.stop();
        }
      }
    }, _callee20);
  }));
  return _setPermissionSetEnable.apply(this, arguments);
}

export function queryPermissionsByMenuId(_x13) {
  return _queryPermissionsByMenuId.apply(this, arguments);
} // 查询权限集下已分配的权限

function _queryPermissionsByMenuId() {
  _queryPermissionsByMenuId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(menuId) {
    var params,
        _args21 = arguments;
    return _regeneratorRuntime.wrap(function _callee21$(_context21) {
      while (1) {
        switch (_context21.prev = _context21.next) {
          case 0:
            params = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {};
            return _context21.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/").concat(menuId, "/assignable-permissions") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/").concat(menuId, "/assignable-permissions"), {
              query: params
            }));

          case 2:
          case "end":
            return _context21.stop();
        }
      }
    }, _callee21);
  }));
  return _queryPermissionsByMenuId.apply(this, arguments);
}

export function queryPermissionsByMenuIdAll(_x14) {
  return _queryPermissionsByMenuIdAll.apply(this, arguments);
} // 查询权限集下已分配的Lov

function _queryPermissionsByMenuIdAll() {
  _queryPermissionsByMenuIdAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(menuId) {
    var params,
        _args22 = arguments;
    return _regeneratorRuntime.wrap(function _callee22$(_context22) {
      while (1) {
        switch (_context22.prev = _context22.next) {
          case 0:
            params = _args22.length > 1 && _args22[1] !== undefined ? _args22[1] : {};
            return _context22.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/permission-set/").concat(menuId, "/permissions") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/permission-set/").concat(menuId, "/permissions"), {
              query: params
            }));

          case 2:
          case "end":
            return _context22.stop();
        }
      }
    }, _callee22);
  }));
  return _queryPermissionsByMenuIdAll.apply(this, arguments);
}

export function queryLovsByMenuIdAll(_x15) {
  return _queryLovsByMenuIdAll.apply(this, arguments);
} // 查询权限集下可分配的所有lov

function _queryLovsByMenuIdAll() {
  _queryLovsByMenuIdAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(menuId) {
    var params,
        _args23 = arguments;
    return _regeneratorRuntime.wrap(function _callee23$(_context23) {
      while (1) {
        switch (_context23.prev = _context23.next) {
          case 0:
            params = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {};
            return _context23.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/permission-set/").concat(menuId, "/lovs") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/permission-set/").concat(menuId, "/lovs"), {
              query: params
            }));

          case 2:
          case "end":
            return _context23.stop();
        }
      }
    }, _callee23);
  }));
  return _queryLovsByMenuIdAll.apply(this, arguments);
}

export function queryLovByMenuId(_x16) {
  return _queryLovByMenuId.apply(this, arguments);
} // 为权限集分配权限(包括Lov)

function _queryLovByMenuId() {
  _queryLovByMenuId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(menuId) {
    var params,
        _args24 = arguments;
    return _regeneratorRuntime.wrap(function _callee24$(_context24) {
      while (1) {
        switch (_context24.prev = _context24.next) {
          case 0:
            params = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : {};
            return _context24.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/").concat(menuId, "/assignable-lovs") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/").concat(menuId, "/assignable-lovs"), {
              query: params
            }));

          case 2:
          case "end":
            return _context24.stop();
        }
      }
    }, _callee24);
  }));
  return _queryLovByMenuId.apply(this, arguments);
}

export function assignPermissions() {
  return _assignPermissions.apply(this, arguments);
} // 回收权限集的权限(包括Lov)

function _assignPermissions() {
  _assignPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
    var params,
        menuId,
        permissionCodes,
        others,
        _args25 = arguments;
    return _regeneratorRuntime.wrap(function _callee25$(_context25) {
      while (1) {
        switch (_context25.prev = _context25.next) {
          case 0:
            params = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
            menuId = params.menuId, permissionCodes = params.permissionCodes, others = _objectWithoutProperties(params, _excluded2);
            return _context25.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/").concat(menuId, "/permission-set/assign-permissions") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/").concat(menuId, "/permission-set/assign-permissions"), {
              method: 'POST',
              query: others,
              body: permissionCodes
            }));

          case 3:
          case "end":
            return _context25.stop();
        }
      }
    }, _callee25);
  }));
  return _assignPermissions.apply(this, arguments);
}

export function deletePermissions() {
  return _deletePermissions.apply(this, arguments);
} // 查询客户化菜单

function _deletePermissions() {
  _deletePermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
    var params,
        menuId,
        permissionCodes,
        _args26 = arguments;
    return _regeneratorRuntime.wrap(function _callee26$(_context26) {
      while (1) {
        switch (_context26.prev = _context26.next) {
          case 0:
            params = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
            menuId = params.menuId, permissionCodes = params.permissionCodes;
            return _context26.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/").concat(menuId, "/permission-set/recycle-permissions") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/").concat(menuId, "/permission-set/recycle-permissions"), {
              method: 'POST',
              body: permissionCodes,
              query: {
                permissionType: 'LOV'
              }
            }));

          case 3:
          case "end":
            return _context26.stop();
        }
      }
    }, _callee26);
  }));
  return _deletePermissions.apply(this, arguments);
}

export function queryOrganizationCustomMenu() {
  return _queryOrganizationCustomMenu.apply(this, arguments);
} // 导出客户化菜单

function _queryOrganizationCustomMenu() {
  _queryOrganizationCustomMenu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
    return _regeneratorRuntime.wrap(function _callee27$(_context27) {
      while (1) {
        switch (_context27.prev = _context27.next) {
          case 0:
            return _context27.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/custom-menu-export-tree")));

          case 1:
          case "end":
            return _context27.stop();
        }
      }
    }, _callee27);
  }));
  return _queryOrganizationCustomMenu.apply(this, arguments);
}

export function exportCustomMenu() {
  return _exportCustomMenu.apply(this, arguments);
} // // 刷新菜单对应你 UI组件权限集
// export async function refreshRoutePermissionSet(menuId) {
//   const requestUrl = organizationRoleLevel
//     ? `${CPAAS_IAM}/cpaas/v1/${tenantId}/menus/${menuId}/permission-set/refresh-menu-ui-permissions`
//     : `${CPAAS_IAM}/cpaas/v1/menus/${menuId}/permission-set/refresh-menu-ui-permissions`;
//   return request(requestUrl, {
//     method: 'POST',
//   });
// }
// 获取当前复制的节点及其子节点

function _exportCustomMenu() {
  _exportCustomMenu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
    var params,
        _args28 = arguments;
    return _regeneratorRuntime.wrap(function _callee28$(_context28) {
      while (1) {
        switch (_context28.prev = _context28.next) {
          case 0:
            params = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {};
            return _context28.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/custom-menu-export"), {
              method: 'POST',
              body: params,
              responseType: 'blob'
            }));

          case 2:
          case "end":
            return _context28.stop();
        }
      }
    }, _callee28);
  }));
  return _exportCustomMenu.apply(this, arguments);
}

export function queryCopyMenuList() {
  return _queryCopyMenuList.apply(this, arguments);
} // 复制并创建菜单

function _queryCopyMenuList() {
  _queryCopyMenuList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
    var params,
        _args29 = arguments;
    return _regeneratorRuntime.wrap(function _callee29$(_context29) {
      while (1) {
        switch (_context29.prev = _context29.next) {
          case 0:
            params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
            return _context29.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/copy") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/copy"), {
              query: params
            }));

          case 2:
          case "end":
            return _context29.stop();
        }
      }
    }, _callee29);
  }));
  return _queryCopyMenuList.apply(this, arguments);
}

export function copyMenu(_x17) {
  return _copyMenu.apply(this, arguments);
}

function _copyMenu() {
  _copyMenu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(payload) {
    var level, data;
    return _regeneratorRuntime.wrap(function _callee30$(_context30) {
      while (1) {
        switch (_context30.prev = _context30.next) {
          case 0:
            level = payload.level, data = payload.data;
            return _context30.abrupt("return", request(organizationRoleLevel ? "".concat(CPAAS_IAM, "/cpaas/v1/").concat(tenantId, "/menus/copy-insert") : "".concat(CPAAS_IAM, "/cpaas/v1/menus/copy-insert?level=").concat(level), {
              method: 'POST',
              body: data
            }));

          case 2:
          case "end":
            return _context30.stop();
        }
      }
    }, _callee30);
  }));
  return _copyMenu.apply(this, arguments);
}